import { createRouter, createWebHistory } from "vue-router";
import newFeatures from "../pages/new-features/index.vue";
import incompatibleFeatures from "../pages/incompatible-features/index.vue";
import abolishFeatures from "../pages/abolish-features/index.vue";
import todoLists from "../pages/todo-lists/index.vue";
import vueRouter4 from "../pages/vue-router4/index.vue";
import vuex4 from "../pages/vuex4/index.vue";

const routes = [
  {
    path: "/newFeatures",
    component: newFeatures,
  },
  {
    path: "/incompatibleFeatures",
    component: incompatibleFeatures,
  },
  {
    path: "/abolishFeatures",
    component: abolishFeatures,
  },
  {
    path: "/todoLists",
    component: todoLists,
  },
  {
    path: "/vueRouter4",
    component: vueRouter4,
  },
  {
    path: "/vuex4",
    component: vuex4,
  },
];

const router = createRouter({
  history: createWebHistory("/vue3-starter"),
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      console.log("savedPosition", savedPosition);
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
